﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Xms.Abp;

namespace Microsoft.Extensions.Hosting;

public static class WebHostServiceBuilderExtensions
{
    public static IHostBuilder UseWebHostService<TStartup, TModule>(this IHostBuilder builder)
        where TStartup : XmsAbpStartup<TModule>
        where TModule : XmsAbpStartupModule
    {
        return builder
            .ConfigureWebHostDefaults(builder =>
            {
                builder.UseStartup<TStartup>();
            })
            .ConfigureServices(services =>
            {
                services.AddHostedService<WebHostServiceWorker<TStartup, TModule>>();
            })
            .UseWindowsService();
    }
}

